<?php
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $ingreso = $_REQUEST['ingreso'];
    
    $tabla = "select grpl.grplc,grf.grflc,pfc.pfcc,crio.crioc,pqm.pqmc,pqa.pqac,st.stc
              from lTransfunc as lt
                      outer apply(select COUNT(*)as grplc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'grpl') as grpl
                      outer apply(select COUNT(*)as grflc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'grf') as grf
                      outer apply(select COUNT(*)as pfcc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'pfc') as pfc
                      outer apply(select COUNT(*)as crioc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'cro') as crio
                      outer apply(select COUNT(*)as pqmc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'pqm') as pqm
                      outer apply(select COUNT(*)as pqac from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'pqa') as pqa
                      outer apply(select COUNT(*)as stc from lTransfunc where adnIngreso = ".$ingreso." and ltr_componente = 'st') as st
              where adnIngreso = ".$ingreso."
              group by grpl.grplc,grf.grflc,pfc.pfcc,crio.crioc,pqm.pqmc,pqa.pqac,st.stc";
    $respu = $con->query($tabla);
    
    while ($respu2 = mssql_fetch_array($respu)){
        $lista[] = $respu2;
    }
    
    print_r(json_encode($lista));
    
    
    $con->cerrarConexion();
?>
